home *** CD-ROM | disk | FTP | other *** search
/ NOVA - For the NeXT Workstation / NOVA - For the NeXT Workstation.iso / Documents / NeXTAnswers / appkit.828 < prev    next >
Text File  |  1992-02-06  |  2KB  |  45 lines

  1. {\rtf0\ansi{\fonttbl\f0\fnil Times-Roman;\f2\fmodern Courier;\f1\fswiss Helvetica;}
  2. \paperw12940
  3. \paperh9000
  4. \margl120
  5. \margr1000
  6. {\colortbl\red0\green0\blue0;}
  7. \pard\tx1140\tx2300\tx3440\tx4600\tx5760\tx6900\tx8060\tx9200\tx10360\tx11520\f0\b0\i0\ul0\fs28\fc0 bug workaround text scaling
  8. \pard\tx960\tx1920\tx2880\tx3840\tx4800\tx5760\tx6720\tx7680\tx8640\tx9600 \
  9. \
  10. Q:  I have built a series of scaled views, and one of my subviews contains a text object.  When I drag the mouse across any text in the text object to select it, there are small white spaces left between the characters.  The selection is not shown as a solid gray highlight and when I drag the mouse back over the text to deselect it, those areas that did get correctly highlighted leave a trace of gray behind.  What's happening?\
  11. \
  12. A:  This is a known problem.  When the text object is in a scaled view,  the highlighting and the insertion point don't display properly, because the display PostScript coordinate system is trying to do its own rounding off of the coordinates.  The current workaround is to use the math C function 
  13. \b floor() 
  14. \b0 to round off your float values before actually setting new coordinate origins.  See also the man pages on
  15. \b   floor()
  16. \b0 .  For example:\
  17. \
  18.  
  19. \pard\tx1140\tx2300\tx3440\tx4600\tx5760\tx6900\tx8060\tx9200\tx10360\tx11520\f2\fs24\fc0 - initText:(char *)aString :(NXSize *)textSize\
  20. \{\
  21.    id text;\
  22.    NXRect containerBounds;\
  23.     \
  24.       /* Allocate MyText Object & Make Subview */\
  25.    text = [[MyText alloc] initText:aString];\
  26.    [self addSubview:text];\
  27.     \
  28.        /* Set new text coordinates */\
  29.    [text sizeTo:textSize.width :textSize.height];\
  30.    [self getBounds:&containerBounds];\
  31. \
  32.     /* Set new text origin (center new text... MUST USE FLOOR HERE!*/\
  33.    [text moveTo:floor((containerBounds.size.width - textSize.width) /2) :0.0];\
  34.    return self;\
  35. \}\
  36.  
  37. \pard\tx960\tx1920\tx2880\tx3840\tx4800\tx5760\tx6720\tx7680\tx8640\tx9600 \
  38.  
  39. \f0\fs28\fc0 QA828\
  40. \
  41. Not tested for 1.0\
  42. Valid for 2.0\
  43. \
  44.  
  45.